//用递归方法计算阶乘
#include<iostream>

int factorial(int);

int main()
{
	int count = 0;
	std::cout << "Please enter the number(n>=0): ";
	while (std::cin >> count && count >= 0)
	{
		int f = factorial(count);
		std::cout << "阶乘结果为：" << f << std::endl;
		std::cin.clear();
	}
	return 0;
}

int factorial(int n)
{
	if (n == 0 || n == 1)
		return 1;
	return n * factorial(n - 1);
}